package bavaria.hightec.banking;

public class Money {
	private long amount;
	private Currency currency;

	public Money(long betrag,Currency waehrung){
		this.amount=betrag;
		this.currency=waehrung;
		
	}
	
	
	public Money addition(long amount,Currency currency){
		Money money=null;
		if(currency == this.currency){
			
			money= new Money(this.amount=this.amount+amount,this.currency);
		}
		else{
			addition(ConvertMoney.convert(amount, currency).getAmount(),this.currency);
			
		}
		return money;
	}
	
	
	public boolean equals(Money money){
		boolean equal= false;
		if((this.amount==money.amount)&&(this.currency==money.currency))
			equal=true;
		return equal;
		
	}
	@Override
	public String toString(){
		String s=amount+" "+currency;
		return s;
	}
	
	
	public long getAmount(){
		return amount;
	}
	public Currency getCurrency(){
		return currency;
	}



	public int compareTo(Money amount1) {
		if(this.amount==amount1.getAmount())
		  return 0;
		else if(this.amount<amount1.getAmount())
			return -1;
		else 
			return 1;
	}
	
}



